package test.lucene;

import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;

import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Terms;
import org.apache.lucene.store.FSDirectory;

public class TermVector {
	
	public static void main(String[] args) {
		FSDirectory fsd = null;
		IndexReader reader = null;
		try {
			fsd = FSDirectory.open(Paths.get(new File("E:\\work\\solr\\solr-5.3.0\\solr_home\\core2\\data\\index").toURI()));
			reader = DirectoryReader.open(fsd);
//			IndexSearcher searcher = new IndexSearcher(reader);
//			TopDocs td = searcher.search(new MatchAllDocsQuery(), 5);
//			for(ScoreDoc sd : td.scoreDocs) {
//				System.out.println(sd.doc);
//			}
			Terms terms = reader.getTermVector(20, "text");
			System.out.println(terms);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				reader.close();
				fsd.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}
